package net.zjitc.service.impl;

import net.zjitc.dao.ProductDao;
import net.zjitc.dao.impl.ProductDaoImpl;
import net.zjitc.domain.Product;
import net.zjitc.service.ProductService;
import net.zjitc.utils.PageBean;

import java.util.List;

/**
 * Created by hasee on 2017/10/27.
 */
public class ProductServiceImpl implements ProductService {
    @Override
    public PageBean findPage(int pageNum, String condition) {
        PageBean pageBean = new PageBean();
        ProductDao dao = new ProductDaoImpl();
        List list = dao.findList(pageNum,pageBean.getListLimit(),condition);
        int count = dao.findCount(condition);
        pageBean.setPageNum(pageNum);
        pageBean.setCondition(condition);
        pageBean.setList(list);
        pageBean.setCount(count);
        return pageBean;
    }

    @Override
    public void insert(Product product) {
        ProductDao dao = new ProductDaoImpl();
        dao.insert(product);
    }

    @Override
    public void remove(String pid) {
        ProductDao dao = new ProductDaoImpl();
        dao.remove(pid);
    }

    @Override
    public Product findById(String pid) {
        ProductDao dao =new ProductDaoImpl();
        return dao.findById(pid);
    }

    @Override
    public void update(Product product) {
        ProductDao dao = new ProductDaoImpl();
        dao.update(product);
    }
}
